#include "SwitchingCheck.h"

#include <QTextStream>

SwitchingCheck::SwitchingCheck(Layer layer,double tol)
{
  QTextStream cout(stdout,QIODevice::WriteOnly);
  //returns true if mag is withing swtiched mag tolerance
  //return false otherwise
  cout<<"switched mag:"<<layer.getSwitchedMag().getX()<<layer.getSwitchedMag().getY()<<layer.getSwitchedMag().getZ()<<endl;
  if((layer.getSwitchedMag().getX()-(tol/100)<layer.getMag().getX() && layer.getMag().getX()<layer.getSwitchedMag().getX()+(tol/100))&&
     (layer.getSwitchedMag().getY()-(tol/100)<layer.getMag().getY() && layer.getMag().getY()<layer.getSwitchedMag().getY()+(tol/100))&& 
     (layer.getSwitchedMag().getZ()-(tol/100)<layer.getMag().getZ() && layer.getMag().getZ()<layer.getSwitchedMag().getZ()+(tol/100)))
    { 
      //std::cout<<"switching"<<std::endl;
      check=true;
    }
  else
    {
      check=false;
      //std::cout<<"not switching"<<std::endl;
    }
  
}


SwitchingCheck::~SwitchingCheck()
{

}
